import React from 'react'
import api from '../../until/index'
import {Table} from 'antd'
import moment from 'moment'
export default class UserVideo extends React.Component{
    formRef = React.createRef()
    constructor(props){
        super(props)
        this.state={
            dataList:[],
            colums:[{title:'#',align:'center',dataIndex:'id',key:'id',render:(text,record,index)=>`${index+1}`},
        {title:'视频标题',align:'center',dataIndex:'videoname',key:'videoname'},
    {title:'视频封面',align:'center',dataIndex:'img',key:'img',render: (text) => <img alt="" key="img" style={{ width: '60px', height: '60px' }} src={text} /> },
    {title:'添加时间',align:'center',dataIndex:'tiem',key:'tiem',render:val=><span>{val?moment(Number(val)).format('YYYY-MM-DD HH:mm:ss'):moment('2020-6-1 00:00:00').format('YYYY-MM-DD HH:mm:ss')}</span>},
    {title:'播放链接',align:'center',dataIndex:'video',key:'video',render:val=><a href={val} target="blank">播放</a>}]
        }
    }
   async componentDidMount(){
        let userid=sessionStorage.getItem('userId')
        let result= await api.getvideo({userid:userid})
        this.setState({
            dataList:result.data.message
        })
        console.log(result)
    }
    render(){
        const {colums,dataList}=this.state
        return(
            <div>
                <Table columns={colums} dataSource={dataList} bordered bottomLeft rowKey={record=>record.id}></Table>
            </div>
        )
    }
}